BUILD = ~/toolchain_3308
CC = $(BUILD)/bin/aarch64-rockchip-linux-gnu-gcc
BIN = rk3308_demo
LDFLAGS +=  -L$(BUILD)/aarch64-rockchip-linux-gnu/sysroot/lib -L$(BUILD)/aarch64-rockchip-linux-gnu/sysroot/usr/lib -L./lib/ -L.

# CC = gcc
# BIN = demo_ubuntu
# LDFLAGS += -lSDL2 -lm

CFLAGS = -Wall -Wshadow -Wundef
# CFLAGS += -lasan -fno-omit-frame-pointer -fsanitize-recover=all -fsanitize=address
#-Wmaybe-uninitialized
CFLAGS += -O3  -I./ -I./inc    -ldrm -L. -g -lpthread -D_GNU_SOURCE -lm -lc  
# -I/home/linux/share/littlevgl/tslib-master/src 

#LDFLAGS += -L/home/linux/share/littlevgl/ -l/home/linux/share/littlevgl/libts.la

VPATH = 
LVGL_DIR ?= ${shell pwd}
$(warning  $(LVGL_DIR)) 
LVGL_DIR_NAME ?= lvgl
MAINSRC = main.c

include ./lvgl/lvgl.mk
#DRIVERS
include ./lv_drivers/lv_drivers.mk
include ./lv_lib_png/lv_lib_png.mk
include ./lv_demos/lv_demo.mk
include ./src/src.mk

OBJEXT ?= .o

AOBJS = $(ASRCS:.S=$(OBJEXT))
COBJS = $(CSRCS:.c=$(OBJEXT))

MAINOBJ = $(MAINSRC:.c=$(OBJEXT))

SRCS = $(ASRCS) $(CSRCS) $(MAINSRC)
OBJS = $(AOBJS) $(COBJS)

## MAINOBJ -> OBJFILESclean 

all: default

%.o: %.c %.h
	@$(CC) -g $(CFLAGS) -c $< -o $@
	@echo "CC $<"

default: $(AOBJS) $(COBJS) $(MAINOBJ)
	echo "------------------" $(AOBJS) $(COBJS) $(MAINOBJ) "------------------"
	$(CC) -g -o $(BIN) $(MAINOBJ) $(AOBJS) $(COBJS) $(LDFLAGS) $(CFLAGS) 
	# rm -f $(AOBJS) $(COBJS) $(MAINOBJ)

clean: 
	rm -f $(AOBJS) $(COBJS) $(MAINOBJ) $(BIN)
